//
//  ShowCell.m
//  7.13苏宁框架
//
//  Created by lovena on 15/7/19.
//  Copyright (c) 2015年 lovena. All rights reserved.
//

#import "ShowCell.h"
#import "Common.h"
@implementation ShowCell

+(id)CreateShopCell
{
    return [[[NSBundle mainBundle]loadNibNamed:@"ShowCell" owner:nil options:nil] lastObject];
}

//重写set
-(void)setSmodel:(ShopModel *)smodel
{
    self.subBtn.enabled=NO;
    _smodel=smodel;
    //图片
    //self.icon.image=[UIImage imageNamed:smodel.icon];
    [self.icon setImageWithURL:[NSURL URLWithString:smodel.icon]];
    
    self.name.text=smodel.name;
    self.price.text=smodel.price;
    self.oldprice.text=smodel.oldprice;
    NSString *cou=[NSString stringWithFormat:@"%i",smodel.count];
    [self.buyCount setTitle:cou forState:UIControlStateNormal];
    
    if(smodel.flag==YES)
    {
        self.selectedBtn.selected=YES;
    }
    else
    {
        self.selectedBtn.selected=NO;
    }
    if (smodel.count>1) {
        self.subBtn.enabled=YES;
        [self.subBtn setBackgroundImage:[UIImage imageNamed:@"ShopCart_numberEdit_delete"] forState:UIControlStateNormal];
    }
    else
    {
        self.subBtn.enabled=NO;
        [self.subBtn setBackgroundImage:[UIImage imageNamed:@"ShopCart_numberEdit_delete_disabled"] forState:UIControlStateNormal];
    }
}


- (IBAction)clickSubBtn:(UIButton *)sender {
    if ([self.delegate respondsToSelector:@selector(shopSubCount:)]) {
        [self.delegate shopSubCount:sender.tag];
    }
}

- (IBAction)clickAddBtn:(UIButton *)sender {
    if ([self.delegate respondsToSelector:@selector(shopAddCount:)]) {
        [self.delegate shopAddCount:sender.tag];
    }
}
//选中方法
- (IBAction)clickSelectedBtn:(UIButton *)sender {
    if ([self.delegate respondsToSelector:@selector(shopSelected:)]) {
        [self.delegate shopSelected:sender];
    }
}
@end
